package hc.um.action;

import hc.um.service.UserService;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * Servlet implementation class QueryUserListServlet
 */
@WebServlet("/QueryUserListServlet")
public class QueryUserListServlet extends HttpServlet {
	private static final long serialVersionUID = 1L;
       
	private UserService userService = new UserService();
	
    /**
     * @see HttpServlet#HttpServlet()
     */
    public QueryUserListServlet() {
        super();
        // TODO Auto-generated constructor stub
    }

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
		
		System.out.println("query user list");
		this.getUserList(request, response);			
	}

	public void getUserList(HttpServletRequest request,
			HttpServletResponse response) throws IOException {
		int RoleID = 0;		
		
		RoleID = Integer.parseInt(request.getParameter("RoleID"));
		
		response.getWriter().write(userService.getUserListRecords(RoleID));
	}	
}
